from selenium.webdriver.common.by import By

from common.base import Base
from common.functions import open_browser


class GoodsPage(Base):

    def home(self):
        self.click((By.LINK_TEXT, '首页'))

    def home_goods(self, i):  # 点击商品
        self.i = i
        self.click((By.XPATH, '//div[@class="all_ms"]/a[%s]' % self.i))

    def home_good_sname(self, i):  # 首页商品名称
        self.i = i
        return self.find_element_text((By.XPATH, '//div[@class="all_ms"]/a[%s]/div[@class="gos-title"]' % self.i))

    def user(self):  # 点击用户中心
        self.click((By.LINK_TEXT, '用户中心'))
